package com.jojo;

import java.util.List;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class MainApp {

    public static void main(String[] args) {

        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");

        StudentJDBCTemplate studentJDBCTemplate = (StudentJDBCTemplate) context.getBean("studentJDBCTemplate");

        System.out.println("------Records Creation--------");
        studentJDBCTemplate.create("Allen", 17);
        studentJDBCTemplate.create("Ray", 18);
        studentJDBCTemplate.create("Mark", 20);

        System.out.println("------Listing Multiple Records--------" );
        List<Student> students = studentJDBCTemplate.listStudents();
        for(Student record : students) {
            System.out.print("ID : " + record.getId());
            System.out.print(",Name : " + record.getName());
            System.out.print(",Age : " + record.getAge());
        }
    }
}